Function CreateSheetWithTextureCoords(width As Single, height As Single, su As Single, eu As Single, sv As Single, ev As Single, texture As Direct3DTexture8) As CD3DFrame
Dim frame As CD3DFrame
Dim mesh As CD3DMesh
Dim retd3dxMesh As D3DXMesh
Dim vertexbuffer As Direct3DVertexBuffer8
Dim verts(8) As D3DVERTEX
Dim indices(12) As Integer
Dim w As Single, d As Single, h1 As Single, h2 As Single
w = width / 2
h2 = height / 2
h1 = -height / 2
d = 0.01
Dim whitematerial As D3DMATERIAL8
whitematerial.diffuse = ColorValue4(1, 1, 1, 1)
whitematerial.Ambient = whitematerial.diffuse
'Create an empty d3dxmesh with room for 12 vertices and 12
Set retd3dxMesh = g_d3dx.CreateMeshFVF(8, 12, D3DXMESH_MANAGED, D3DFVF_VERTEX, g_dev)
'front face
'add vertices
With verts(0): .x = -w: .y = h2: .z = -d: .nz = 1: .tu = su: .tv = sv: End With
With verts(1): .x = w: .y = h2: .z = -d: .nz = 1: .tu = eu: .tv = sv: End With
With verts(2): .x = w: .y = h1: .z = -d: .nz = 1: .tu = eu: .tv = ev: End With
With verts(3): .x = -w: .y = h1: .z = -d: .nz = 1: .tu = su: .tv = ev: End With
'connect verices to make 2 triangles per face
indices(0) = 0: indices(1) = 1: indices(2) = 2
indices(3) = 0: indices(4) = 2: indices(5) = 3
'back face
With verts(4): .x = -w: .y = h1: .z = d: .nz = -1: .tu = eu: .tv = ev: End With
With verts(5): .x = w: .y = h1: .z = d: .nz = -1: .tu = su: .tv = ev: End With
With verts(6): .x = w: .y = h2: .z = d: .nz = -1: .tu = su: .tv = sv: End With
With verts(7): .x = -w: .y = h2: .z = d: .nz = -1: .tu = eu: .tv = sv: End With